﻿
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>公式更新</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/X-admin/lib/layui/layui.js"></script>
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
</head>
<body>
    <ul lay-bar="disabled" class="mWebBanner">
        <li class="layui-nav-item" style="float:left;">
            <button id="btn-update" type="button" name="btn_update" onclick="saveData()" class="buttonCss">
                保存数据
            </button>
        </li>
        <li class="layui-nav-item" style="float:left;padding-left:20px">
            <button id="btn-sync" type="button" onclick="closeWin()" class="buttonCss">
                关闭页面
            </button>
        </li>
    </ul>
    <div class="layui-card" style="margin-top:10px">
        <div class="layui-card-body" style="padding-top:3%">
            <form class="layui-form" id="uForm" >
                    <div class="layui-form-item">
                        <label class="layui-form-label">公式名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="gsName"  autocomplete="off" class="layui-input" id="gsName" >
                            <input type="hidden" name="id" id="id">
                        </div>
                         <label class="layui-form-label"><span class="x-red">*</span>绩效类型</label>
                        <div class="layui-input-inline">
                            <select name="gsType" id="gsType">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                  <div class="layui-form-item layui-form-text">
                        <label for="L_email" class="layui-form-label">
                         关联名称
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="relationName" name="relationName" autocomplete="off" class="layui-input">
                            <input type="hidden" id="relationCode" name="relationCode" autocomplete="off" class="layui-input">
                            <input type="hidden" id="id" name="id" autocomplete="off" class="layui-input">
                        </div>

                    </div>

                    <div  style="margin-bottom:5px;margin-left:13%;color:red;">注意：计算公式必须含有关键字：[number]，作为生产数量字段</div>
                    <div class="layui-form-item layui-form-text">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>计算公式
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="formula" name="formula" class="layui-input" >
                        </div>
                        
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label for="L_email" class="layui-form-label">
                           绩效备注
                        </label>
                        <div class="layui-input-block">
                            <input type="text" id="memo" name="memo" autocomplete="off" class="layui-input">
                        </div>

                    </div>
                  

                </form>
        </div>
      
    </div>
</body>
</html>
<script>
    var dataId = "";
    $(function () {

        DictionaryDropDown("pqt", "gsType", "all");
        dataId = getUrlVariable("dataId");
        if (dataId != "0") {
            $("input[ name='id']").val(dataId);
            loadDataById(dataId); //加载用户数据
        }
    })
    /**
    数据保存
    **/
    function saveData() {
        $.ajax({
            url: "../Wage/UpdateFormula",
            data: { data: JSON.stringify(FormToJson("uForm")) },
            dataType: "json",
            type: "POST",
            success: function (rsl) {
                if (rsl.result) {
                    layer.alert("保存成功", { icon: 6 }, function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                    });
                } else {
                    layer.msg(rsl.message);
                }
            }
        });
    }

    //加载用户数据信息
    function loadDataById(dataId) {
        $.ajax({
            url: "../Wage/loadFormulaByID",
            type: "post",
            data: { dataId: dataId },
            success: function (rsl) {

                if (rsl.result) {

                    $.each(rsl.data[0], function (name, value) {
                        if (name != "gsType") {
                            $("input[ name='" + name + "']").val(value);
                        } else {
                            $("#gsType option[value='" + value + "'] ").attr("selected", true);
                            layui.use('form', function () {
                                var form = layui.form;
                                form.render();
                            });
                        }

                    });

                }

            }
        });

    }


</script>

